package jzoffer.jz54;



import java.util.ArrayList;
import java.util.List;

class Solution {
    public int kthLargest(TreeNode root, int k) {
        List<TreeNode> list = new ArrayList<>();
        fixOrder(root,list,k);

        return list.get(k).val;
    }
    //中序遍历
    static void fixOrder(TreeNode node, List<TreeNode> list,int k){
        if (node != null){
            fixOrder(node.left,list,k);
            list.add(node);
            fixOrder(node.right,list,k);
        }
    }
    static class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode (int x){ val = x; }
    }
}
